package com.itheima.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.mapper.OrderMapper;
import com.itheima.pojo.Order;
import com.itheima.pojo.vo.OrderVO;
import com.itheima.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class OrderServiceImpl implements OrderService {
    @Autowired
    private OrderMapper orderMapper;

    /**
     * 分页查询
     * @param queryPageBean
     * @return
     */
    @Override
    public PageResult findPage(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        Page<OrderVO> page=orderMapper.findPage(queryPageBean.getQueryString());
        for(OrderVO orderVO:page){
            orderVO.setFileNumber(orderVO.getId());
        }
        return new PageResult(page.getTotal(),page.getResult());
    }

    /**
     * 修改预约状态
     * @param id
     * @param orderStatus
     */
    @Override
    public void update(Integer id, String orderStatus) {
        orderMapper.update(id,orderStatus);
    }
}
